/** 
 * @file 2.虚拟继承.cpp
 * @author 18-工程视觉-黄星照
 * @brief 阅读下列代码，回答代码是否能通过编译，
 *            如可以，请回答代码的输出；
 *            如不行，请回答编译器报错原因，并修改，然后回答代码输出。
 * @date 2020-09-25
 */
#include <iostream>

class A
{
public:
    A()
    {
        ::std::cout << "A constructor.\n";
    }
    ~A()
    {
        ::std::cout << "A destructor.\n";
    }
    int num;
};

class B1:virtual public A
{
public:
    B1() = default;
    ~B1() = default;
};

class B2:virtual public A
{
public:
    B2() = default;
    ~B2() = default;
};
class C: virtual public B1, virtual public B2
{
public:
    C()
    {
        ::std::cout << "C constructor.\n";
        B1::num = 0;
        B2::num = 1;
    }
    ~C()
    {
        ::std::cout << "C destructor.\n";
    }
    bool is_equal()
    {
        return B1::num == B2::num;
    }
};

int main()
{
    C c;
    ::std::cout<<c.is_equal()<<::std::endl;
}